package com.ruoyi.ws.facade;


import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.AdminSubject;
import com.ruoyi.system.service.IAdminSubjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import static com.ruoyi.common.core.domain.AjaxResult.error;
import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * 课程相关接口
 *
 * @author roytrack
 * @date 2020-05-25 17:37:24
 */
@RestController
@RequestMapping(path = "services/subject")
public class SubjectResource {

  /**
   * LOGGER
   */
  private static final Logger LOGGER = LoggerFactory.getLogger(SubjectResource.class);
  @Autowired
  private IAdminSubjectService adminSubjectService;

  /**
   * 根据等级查询标准课程
   * @param level
   * @return
   */
  @PostMapping("/getStandardSubject")
  @ResponseBody
  public AjaxResult getStandardSubject (String level) {
    try {
      //学生班级关系表
      AdminSubject adminSubject  = new AdminSubject();
      adminSubject.setSubjectType("1");//标准课程
      adminSubject.setSubjectLevel(level);
      List<AdminSubject> adminSubjectList = adminSubjectService.selectAdminSubjectList(adminSubject);
      return success(adminSubjectList);
    } catch (Exception e) {
      LOGGER.info("根据等级查询标准课程",e);
      return error("根据等级查询标准课程");
    }
  }

}
